Page({
    /**
     * 页面的初始数据
     */
    data: {
      option1: [
        { text: '中文', value: "cn" },
        { text: '英语', value: "en" },
        { text: '日语', value: "ja" },
        { text: '韩语', value: "ko" },
        { text: '俄语', value: "ru" },
        { text: '法语', value: "fr" }
      ],
      option2: [
        { text: '中文', value: "cn" },
        { text: '英语', value: "en" },
        { text: '日语', value: "ja" },
        { text: '韩语', value: "ko" },
        { text: '俄语', value: "ru" },
        { text: '法语', value: "fr" }
      ],
      value1: "cn",
      value2: "en",
      data: ""
    },
    formSubmit(e) {
      console.log(e);
      var that = this;
      wx.request({
        url: 'http://10.121.21.217:8080/naturalLanguage/translation',
        method: "GET",
        data: {
          from: e.detail.value.a,
          to: e.detail.value.b,
          text: e.detail.value.text,
        },
        dataType: "json",
        success: function (result) {
          console.log(result);
          if (result.data.code == 200) {
            that.setData({
              data: JSON.parse(result.data.data).dst
            });
          } else {
            wx.showToast({
              title: result.data.data,
              icon: "error"
            });
          }
        }
      });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      wx.setNavigationBarTitle({
        title: "机器翻译"
      });
    }
  });